<template>
	<view class="content">
		<div class="slide" style="width: 100%;">
			<image src="../../static/images/banner.jpg" mode="widthFix"></image>
		</div>
		<view class="main">
			<div class="list">
				<div class="items" v-for="(item,index) in list" :key="index" @tap="toShopInfo(index,item.id)">
					<image :src="item.thumb" mode="aspectFit"></image>
					<div class="r">
						<h3 class="title">{{item.title}}</h3>
						<p class="desc">{{item.description}}</p>
						<div class="price">
							¥<span>{{item.price}}</span>
						</div>
					</div>
					<!-- <p class="add" @tap.stop="innerClick"></p> -->
				</div>
			</div>
			<!-- <button type="primary" plain="true" @tap="toGift" class="btn">送礼/分享</button> -->
		</view>
	</view>
</template>

<script>
	import {
		request
	} from '@/utils/request.js'
	export default {
		data() {
			return {
				title: 'Hello',
				list: [{
						thumb: '/static/images/shop2.jpg',
						title: '冰火泉380ml',
						description: '矿泉水',
						price: '74'
					},
					{
						image: '/static/images/shop1.jpg',
						title: '天然水 1L',
						desc: '矿泉水',
						price: '74'
					}

				]
			}
		},
		onLoad(options) {
			 uni.$emit('setUid', options.uid)
			console.log(options)
			this.getShopList()

		},
		methods: {

			getShopList() {
				request({
					url: 'site/index',
					method: 'get',
					data: {}
				}).then(res => {
					if (res.status == 200) {
							this.list = res.data.goods
					}
				})
			},
			toShopInfo(index,id) {
				console.log('外层点击', index);
				uni.navigateTo({
					url: '/pages/shopInfo/shopInfo?id='+id,
					success: res => {},
					fail: () => {},
					complete: () => {}
				});
			},
			innerClick(e) {
				console.log('内层点击');
			},
			toGift() {
				uni.navigateTo({
					url: '/pages/gift/gift',
					success: res => {},
					fail: () => {},
					complete: () => {}
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	.main {
		.btn {
			width: 400rpx;
			height: 80rpx;
			line-height: 80rpx;
			font-size: 28rpx;
			background-color: rgb(74, 144, 226);
			border-radius: 40rpx;
			color: rgb(255, 255, 255);
			border: none;
		}
	}

	.list {
		padding: 30rpx;

		.items {
			box-sizing: border-box;
			box-shadow: 0 0 14px rgba(0, 0, 0, .1);
			height: 258rpx;
			padding: 12rpx;
			margin-bottom: 30rpx;
			border-radius: 10rpx;
			display: flex;
			align-items: center;
			position: relative;

			image {
				height: 228rpx;
				width: 228rpx;
				margin-right: 20rpx;
			}

			.add {
				background: url(/static/images/add.png) no-repeat;
				background-size: 100% 100%;
				width: 50rpx;
				height: 50rpx;
				display: block;
				position: absolute;
				bottom: 12rpx;
				right: 12rpx;
			}

			.r {
				width: 200rpx;
				height: 100%;
				display: flex;
				flex-direction: column;
				justify-content: space-between;
				flex: 1;

				.title {
					font-size: 32rpx;
				}

				.desc {
					font-size: 28rpx;
					  overflow: hidden;
					  display: -webkit-box;
					      -webkit-box-orient: vertical;
					      -webkit-line-clamp: 2;
					color: #666;
				}

				.price {
					color: #4a90e2;
					font-size: 25rpx;

					span {
						font-size: 32rpx;
					}
				}
			}
		}
	}

	.slide {
		width: 100%;

		image {
			width: 100%;
		}

		swiper {
			height: 360rpx;

			.swiper-item {
				width: 100%;
				height: 100%;
			}


		}
	}
</style>